package com.topscore.uke.mvp.presenters;

import com.topscore.uke.entities.MemberEntity;
import com.topscore.uke.mvp.contractors.GetMemberListContractor;
import com.topscore.uke.mvp.model.GetMemberListModel;
import com.topscore.uke.utils.UserInfoManager;

import java.util.List;

/**
 * Created by 71468 on 2017/11/8.
 */

public class GetMemberListPresenter implements GetMemberListContractor, GetMemberListContractor.Presenter {
    private Model mModel;
    private View mView;

    public GetMemberListPresenter(View view) {
        this.mView = view;
        this.mModel = new GetMemberListModel(new CallBack() {
            @Override
            public void onGetListSuccess(List<MemberEntity> list) {
                mView.onGetMemberListSuccess(list);
            }

            @Override
            public void onError(int errorCode, String errorMessage) {
                mView.onFail(errorCode, errorMessage);
            }

            @Override
            public void onComplete() {
                mView.onLoadFinished();
            }
        });
    }

    @Override
    public void getMemberList() {
        mView.onLoading("正在获取会员列表");
        String userId = UserInfoManager.getUserInfo().getLoginName();
        String role = UserInfoManager.getUserInfo().getRole();
        mModel.getList(userId, role);
    }
}
